home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-10-22 | 2.2 KB | 81 lines | [TEXT/KAHL] |
- // Copyright: © 1992 by Apple Computer, Inc., all rights reserved.
-
- #include "mtb.h"
-
- void AddVideoSamplesToMedia (Media theMedia,
- const Rect *trackFrame)
- {
- long maxCompressedSize;
- GWorldPtr theGWorld = nil;
- long curSample;
- Handle compressedData = nil;
- Ptr compressedDataPtr;
- ImageDescriptionHandle imageDesc = nil;
- CGrafPtr oldPort;
- GDHandle oldGDeviceH;
- OSErr err = noErr;
-
- err = NewGWorld ( &theGWorld,
- 16, // pixel depth
- trackFrame,
- nil,
- nil,
- (GWorldFlags) 0 );
- CheckError (err, "\pNewGWorld");
-
- LockPixels (theGWorld->portPixMap);
-
- err = GetMaxCompressionSize (theGWorld->portPixMap,
- trackFrame,
- 0, // let ICM choose depth
- codecNormalQuality,
- 'rle ',
- (CompressorComponent) anyCodec,
- &maxCompressedSize );
- CheckError (err, "\pGetMaxCompressionSize" );
-
- compressedData = NewHandle(maxCompressedSize);
- CheckError( MemError(), "\pNewHandle" );
-
- MoveHHi( compressedData );
- HLock( compressedData );
- compressedDataPtr = StripAddress( *compressedData );
-
- imageDesc = (ImageDescriptionHandle)NewHandle(4);
- CheckError( MemError(), "\pNewHandle" );
-
- GetGWorld (&oldPort, &oldGDeviceH);
- SetGWorld (theGWorld, nil);
-
- //••••••• changed to <= 30
- for (curSample = 1; curSample <= 30; curSample++) {
- EraseRect (trackFrame);
- DrawFrame(trackFrame, curSample);
-
- err = CompressImage ( theGWorld->portPixMap,
- trackFrame,
- codecNormalQuality,
- 'rle ',
- imageDesc,
- compressedDataPtr );
- CheckError( err, "\pCompressImage" );
-
- err = AddMediaSample(theMedia,
- compressedData,
- 0, // no offset in data
- (**imageDesc).dataSize,
- 60, // frame duration = 1/10 sec
- (SampleDescriptionHandle)imageDesc,
- 1, // one sample
- 0, // self-contained samples
- nil);
- CheckError( err, "\pAddMediaSample" );
- }
-
- SetGWorld (oldPort, oldGDeviceH);
-
- if (imageDesc) DisposeHandle ((Handle)imageDesc);
- if (compressedData) DisposeHandle (compressedData);
- if (theGWorld) DisposeGWorld (theGWorld);
- }
-